

var ScreenResize: any = {
  designWidth: 1920,
  designHeight: 1080,
  minHeight: 768,
  minWidth: 1280,

  resize: function () {
    scale: this.designWidth / this.designHeight;
    var htmlWidth = Math.max(document.documentElement.clientWidth, ScreenResize.minWidth)
    var htmlHeight = Math.max(document.documentElement.clientHeight, ScreenResize.minHeight);
    document.documentElement.style.fontSize = (htmlHeight / (ScreenResize.designHeight / 100)) + "px";
    document.documentElement.style.minHeight = ScreenResize.minHeight + "px";
    document.documentElement.style.minWidth = ScreenResize.minWidth + "px";
    document.documentElement.style.width = htmlWidth + "px";
    document.documentElement.style.height = htmlHeight + "px";
  }
};
ScreenResize.resize();

var throttle = function (func: any, delay: number) {
  var timer: any = null;
  var startTime = Date.now();
  return function () {
    var curTime = Date.now();
    var remaining = delay - (curTime - startTime);
    clearTimeout(timer);
    if (remaining <= 0) {
      func();
      startTime = Date.now();
    } else {
      timer = setTimeout(func, remaining);
    }
  }
}
window.addEventListener('resize', throttle(() => ScreenResize.resize(), 1000));
